package com.iwhalecloud.bss.kite.cucc.service.route.match.impl;

import java.util.Objects;

import com.iwhalecloud.bss.kite.cucc.client.dto.inf.InfServContextDTO;
import com.iwhalecloud.bss.kite.cucc.service.pos.handler.CuccPosServiceUtils;
import com.iwhalecloud.bss.kite.cucc.service.route.InfServReqParam;
import com.iwhalecloud.bss.kite.cucc.service.route.strategy.impl.InfBcmcServiceBusStrategy;
import com.iwhalecloud.bss.kite.manager.inst.KiteOfferInst;

/**
 * <Description> <br>
 * 商品分类匹配
 *
 * @author XXX<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2020年12月4日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.service.route.impl <br>
 */
public class GoodsCategroyMatchHandler extends AbstractInfServRouteHandler {

    @Override
    public void doHandle(InfServReqParam request) {

        InfServContextDTO context = request.getContext();

        // 获取场景中受理根商品实例
        KiteOfferInst offerInst = CuccPosServiceUtils.getRootOfferInst(context.getSceneInstId(),
            context.getCustDto().getCustId());
        if (Objects.nonNull(offerInst)) {
            // 判断商品分类是否属于配置中
            if (CuccPosServiceUtils.checkBcmcGoodsCategroy(offerInst.getOfferId())) {
                request.setInfServStrategy(new InfBcmcServiceBusStrategy());
                // 满足调条件，终止调度，返回服务策略
                request.setAbort(Boolean.TRUE);
            }
        }
    }
}
